<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!in_array('loveb_qd',$QXARR))exit(noauth());
switch ($submitok) {
	case"alldel":
		$tmeplist = $list;
		if(empty($tmeplist))json_exit(array('flag'=>0,'msg'=>'请选择您要删除的信息'));
		if(!is_array($tmeplist))exit(JSON_ERROR);
		if(count($tmeplist)>=1){
			foreach($tmeplist as $value){$v=intval($value);
				$row2 = $db->ROW(__TBL_LOVEB_LIST__,"uid,num","id=".$v,'num');$uid= $row2[0];$num= $row2[1];
				$row2 = $db->ROW(__TBL_USER__,"nickname","id=".$uid,'num');$nickname= $row2[0];
				$db->query("DELETE FROM ".__TBL_LOVEB_LIST__." WHERE id=".$v);
				AddLog('批量删除用户【'.$nickname.'（uid:'.$uid.'）】'.$_ZEAI['loveB'].'清单，清单金额：'.$num);
			}
			$list = (is_array($tmeplist))?implode(',',$tmeplist):'';$uid=0;
		}
		json_exit(array('flag'=>1,'msg'=>'删除成功'));
	break;
}
$SQL = "";
$Skeyword = trimm($Skeyword);
if (ifint($Skeyword)){
	$SQL = " AND (b.id=$Skeyword) ";
}elseif(!empty($Skeyword)){
	$SQL = " AND ( ( b.uname LIKE '%".$Skeyword."%' ) OR ( b.nickname LIKE '%".$Skeyword."%' ) OR ( b.nickname LIKE '%".urlencode($Skeyword)."%' ) )";
}
if(!empty($Skeyword2)){
	$SQL = " AND ( a.content LIKE '%".$Skeyword2."%' )";
}
if (ifint($uid)){
	$SQL = " AND (a.uid=$uid) ";
	$_ADM['admPageSize']=8;
}
switch ($sort) {
	default:$SORT = " ORDER BY id DESC ";break;
}
$rt = $db->query("SELECT a.*,b.sex,b.grade,b.nickname FROM ".__TBL_LOVEB_LIST__." a,".__TBL_USER__." b WHERE a.uid=b.id ".$SQL.$SORT." LIMIT ".$_ADM['admLimit']);
$total = $db->num_rows($rt);?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<style>.box{min-width:1000px;padding:0}</style>
</head>
<body>
<div class="box">
	<div class="boxL">
    	<a href="loveb.php" class="ed"><?php echo $_ZEAI['loveB']; ?>账户清单<?php echo '<b>'.$total.'</b>';?></a>
	</div>
	<div class="boxR">
        <div class="topsearch">
            <form name="ZEAI_CN__form1" method="get" action="<?php echo SELF; ?>">
                <input name="Skeyword" type="text" id="Skeyword" maxlength="25" class="input size2 W150" placeholder="按UID/用户名/昵称" value="<?php echo $Skeyword; ?>">
                <input type="hidden" name="p" value="<?php echo $p;?>" />
                <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
            </form>
            <form name="ZEAI_CN__form2" method="get" action="<?php echo $SELF; ?>" style="margin-left:30px">
                <input name="Skeyword2" type="text" id="Skeyword2" maxlength="25" class="input size2 W150" placeholder="按结算项目内容" value="<?php echo $Skeyword2; ?>">
                <input type="hidden" name="p" value="<?php echo $p;?>" />
                <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
            </form>  
        </div>
        <!---->
		<?php
        if ($total <= 0 ) {
            echo "<div class='nodataico'><i></i>暂无内容";
            if (!ifint($uid))echo"<br><a class='aQINGed' href='javascript:history.back(-1)'>返回上一页</a>";
            echo "</div>";
        } else {
            $page_skin=2;$pagemode=3;$pagesize=$_ADM['admPageSize'];require_once ZEAI.'sub/page.php';?>
            <form id="www_zeai_cn_FORM" method="get" action="<?php echo SELF; ?>">
            <table class="tablelist">
            <tr>
            <th width="20"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
            <th width="50">ID</th>
            <th width="220" align="left">会员</th>
            <th width="160">结算时间</th>
            <th align="left" >结算项目</th>
            <th width="100">加减(个)</th>
            <th width="100">余额(个)</th>
            <th width="34">&nbsp;</th>
            </tr>
            <?php
            for($i=1;$i<=$pagesize;$i++) {
                $rows = $db->fetch_array($rt,'name');
                if(!$rows) break;
                $id = $rows['id'];$uid = $rows['uid'];
                $uname = strip_tags($rows['uname']);
                $uname = str_replace($Skeyword,"<font color=red><b>".$Skeyword."</b></font>",$uname);
                $nickname = dataIO($rows['nickname'],'out');
                $nickname = str_replace($Skeyword,"<font color=red><b>".$Skeyword."</b></font>",$nickname);
                $sex       = $rows['sex'];
                $grade     = $rows['grade'];
                if(empty($rows['nickname'])){
                    $nickname = $uname;
                }
                $content = dataIO($rows['content'],'out');
                $content = str_replace($Skeyword2,"<font color=red><b>".$Skeyword2."</b></font>",$content);
                $num = $rows['num'];
                $endnum  = $rows['endnum'];
                if ($num<0){
                    $numstyle = " Clan";
                }else{
                    $numstyle = " C090";
                    $num = '+'.$num;
                }
                $addtime = YmdHis($rows['addtime']);
            ?>
            <tr id="tr<?php echo $id;?>">
              <td width="20" height="40"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $uid; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
                </td>
                <td width="50" class="C999"><label for="id<?php echo $id; ?>"><?php echo $id;?></label></td>
                <td width="220" align="left"><a href="<?php echo Href('crm_u',$uid);?>">
                <?php
                echo uicon($sex.$grade);
                echo '<span class="middle">';
                echo $nickname."　<font class='S12 C999'>(uid：".$uid.")</font>";
                echo '</span>';
                ?>
                </a></td>
              <td width="160" align="left" class="S12"><?php echo $addtime;?></td>
              <td align="left"><?php echo $content; ?></td>
            <td width="100" class="<?php echo $numstyle; ?>"><?php echo $num;?></td>
              <td width="100"><?php echo $endnum; ?></td>
              <td width="34">&nbsp;</td>
            </tr>
            <?php } ?>
        </table>
      </form>
        <?php }?>
        <!---->
	</div>
    <div class="clear"></div>
</div>
<?php if ($total > 0){?>
<div class="listbottombox ">
	<input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
	<button type="button" id="btndellist" class="btn size2 HEI2 disabled action">批量删除</button>　
	<button type="button" id="btnsend" value="" class="btn size2 disabled action" onClick="sendTipFn2(this);"><i class="ico">&#xe676;</i> 发送消息</button>
	<input type="hidden" name="submitok" id="submitok" value="" />
	<?php if ($total > $pagesize)echo '<div class="pagebox FR">'.$pagelist.'</div>'; ?>
</div>
<script>
var bg = '<?php echo $_Style['list_bg']; ?>',overbg = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';
o('btndellist').onclick = function() {
	allList({
		btnobj:this,
		url:'loveb'+zeai.ajxext+'submitok=alldel',
		title:'批量删除',
		msg:'正在删除中...',
		ifjson:true,
		ifconfirm:true
	});	
}
</script>
<script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php }?>
<?php require_once 'bottomadm.php';?>